import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

const path = require('path')
// 按需加载加载Antdv
import ViteComponents, {
    AntDesignVueResolver,
} from 'vite-plugin-components'

export default defineConfig({
    plugins: [vue(), vueJsx(),
        ViteComponents({
            customComponentResolvers: [
                AntDesignVueResolver()
            ]
        })],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        },
        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    },
    build: {
        // cssCodeSplit: false
    },
    css: {
        preprocessorOptions:{
            less: {
                modifyVars: {
                    'primary-color': '#1DA57A',
                },
                javascriptEnabled: true,
            },
        },
    },
    server: {
        host:'0.0.0.0',
        proxy: {
            '/api': {
                // target: 'http://192.168.31.15:7055/merchant-domain',
                // target: 'http://dc.fariso.top/system-domain/',
                target: 'http://partner.test.fariso.top/system-domain/',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
        }
    }
})
